package timbap.visualizer.api.context;

import processing.core.PApplet;
import timbap.visualizer.api.context.messaging.MessagingManager;
import timbap.visualizer.api.context.playlist.PlaylistManager;
import timbap.visualizer.api.context.recorditems.RecordItemManager;
import timbap.visualizer.api.context.textures.TextureCacheManager;

/**
 * The <code>AbstractPluginContext</code> class represents the context
 * that is accessible for every plugin. It contains a reference
 * to the processing applet, the timbap configuration and all relevant
 * manager instances.
 *
 * @author  Andreas Pabst
 * @see     timbap.visualizer.api.context.PluginContext
 */
public abstract class AbstractPluginContext<T> implements PluginContext<T> {

    PApplet p5Applet;
    Configuration cfg;
    PlaylistManager playlistManager;
    RecordItemManager recordItemManager;
    TextureCacheManager textureCacheManager;
    MessagingManager<T> messagingManager;

    public abstract PluginContext<T> cloneContext();

    public AbstractPluginContext(PApplet pP5Applet, Configuration pCfg,
                         PlaylistManager pPlaylistManager,
                         RecordItemManager pRecordItemManager,
                         TextureCacheManager pTextureCacheManager,
                         MessagingManager<T> pMessagingManager) {

        p5Applet = pP5Applet;
        cfg = pCfg;
        playlistManager = pPlaylistManager;
        recordItemManager = pRecordItemManager;
        textureCacheManager = pTextureCacheManager;
        messagingManager = pMessagingManager;
    }

    public RecordItemManager getRecordItemManager() {
        return recordItemManager;
    }

    public void setRecordItemManager(RecordItemManager pRecordItemManager) {
        recordItemManager = pRecordItemManager;
    }

    public PlaylistManager getPlaylistManager() {
        return playlistManager;
    }

    public void setPlaylistManager(PlaylistManager pPlaylistManager) {
        playlistManager = pPlaylistManager;
    }

    public Configuration getCfg() {
        return cfg;
    }

    public void setCfg(Configuration pCfg) {
        cfg = pCfg;
    }

    public PApplet getP5Applet() {
        return p5Applet;
    }

    public void setP5Applet(PApplet pP5Applet) {
        p5Applet = pP5Applet;
    }

    public TextureCacheManager getTextureCacheManager() {
        return textureCacheManager;
    }

    public void setTextureCacheManager(TextureCacheManager pTextureCacheManager) {
        textureCacheManager = pTextureCacheManager;
    }

    public MessagingManager<T> getMessagingManager() {
        return messagingManager;
    }

    public void setMessagingManager(MessagingManager<T> pMessagingManager) {
        messagingManager = pMessagingManager;
    }

}